home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / DefaultSelectionData.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  5.9 KB  |  164 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import Select
  6. import Raster
  7. import Actions
  8. import Reference
  9. import CharStats
  10. import math
  11. import netgame
  12. import BUIx
  13. import Language
  14. Label_Opacity = 1.0
  15. Label_r = 128
  16. Label_g = 128
  17. Label_b = 128
  18. if netgame.GetNetState() != 2:
  19.     Select.TurnOnAutoSelect('Player1')
  20.     font_server_behaviour = BUIx.B_FontServer()
  21.     font_behaviour = font_server_behaviour.CreateBFont('../../Data/Letras menu med.bmp')
  22.  
  23. execfile('../../Data/ObjIds/' + Language.Current + '.py')
  24. stime = -2.0
  25.  
  26. def SelectObject():
  27.     global stime
  28.     time = Bladex.GetTime()
  29.     if time - stime > 0.2:
  30.         pj = Bladex.GetEntity('Player1')
  31.         if pj.Data.selection_locked and time - stime < 2.0:
  32.             Select.SelectNext(pj)
  33.         else:
  34.             Select.AutoSelect(pj)
  35.             if pj.Data.selected_entity:
  36.                 pj.Data.selection_locked = 1
  37.             
  38.         stime = time
  39.     
  40.  
  41.  
  42. def UnSelectObject():
  43.     global stime
  44.     stime = -2.0
  45.     pj = Bladex.GetEntity('Player1')
  46.     pj.Data.selection_locked = 0
  47.  
  48. stime2 = -2.0
  49.  
  50. def IntermediateSelect(EntityName):
  51.     SelectEnemy()
  52.  
  53.  
  54. def SelectEnemy():
  55.     global stime2
  56.     time = Bladex.GetTime()
  57.     if time - stime2 > 0.1:
  58.         pj = Bladex.GetEntity('Player1')
  59.         if pj.InvRight == '' and pj.InvRightBack != '' and Reference.GiveObjectFlag(pj.InvRightBack) != Reference.OBJ_QUIVER:
  60.             if pj.AnmEndedFunc == IntermediateSelect:
  61.                 pj.AnmEndedFunc = None
  62.             
  63.             Actions.StdToggleWeapons('Player1')
  64.             pj.AnmEndedFunc = IntermediateSelect
  65.             return None
  66.         
  67.         if pj.Data.enemy_locked:
  68.             Select.SelectNextEnemy(pj)
  69.         else:
  70.             Select.GetVisibleEnemies(pj)
  71.             if pj.Data.selected_enemy:
  72.                 pj.Data.enemy_locked = 1
  73.             
  74.         stime2 = time
  75.         if pj.Data.selected_enemy:
  76.             ene = Bladex.GetEntity(pj.Data.selected_enemy[0])
  77.             if ene and ene.Person:
  78.                 pj.SetActiveEnemy(ene)
  79.             
  80.         
  81.     
  82.  
  83.  
  84. def LabelEntity(entity_name, text, dx, dy):
  85.     entity = Bladex.GetEntity(entity_name)
  86.     if entity:
  87.         screen = Bladex.GetScreenRect()
  88.         text_wh = Bladex.GetTextWH(text)
  89.         text_pos = Bladex.GetScreenXY(entity.Rel2AbsPoint(0.0, 0.0, 0.0))
  90.         text_x = (text_pos[0] - text_wh[0] / 2.0) + dx
  91.         text_y = (text_pos[1] - text_wh[1] / 2.0) + dy
  92.         if text_x < screen[0]:
  93.             text_x = screen[0]
  94.         
  95.         if text_x + text_wh[0] > screen[2]:
  96.             text_x = screen[2] - text_wh[0]
  97.         
  98.         if text_y < screen[1]:
  99.             text_y = screen[1]
  100.         
  101.         if text_y + text_wh[1] > screen[3]:
  102.             text_y = screen[3] - text_wh[1]
  103.         
  104.         Raster.SetFont(font_behaviour.GetPointer())
  105.         Bladex.WriteText(text_x, text_y, text)
  106.     
  107.  
  108.  
  109. def ShowLabelEntity(pj, time):
  110.     itime = time - stime
  111.     if itime <= 0.5:
  112.         Raster.SetTextColor(0, 0, 0)
  113.         Raster.SetTextAlpha(Label_Opacity * 2.0 * itime)
  114.         LabelEntity(pj.Data.selected_entity[0], pj.Data.selected_entity[1][2], 1.0 / 640.0, 1.0 / 640.0)
  115.         Raster.SetTextColor(Label_r, Label_g, Label_b)
  116.         LabelEntity(pj.Data.selected_entity[0], pj.Data.selected_entity[1][2], 0, 0)
  117.     elif itime <= 1.0:
  118.         Raster.SetTextColor(0, 0, 0)
  119.         Raster.SetTextAlpha(Label_Opacity)
  120.         LabelEntity(pj.Data.selected_entity[0], pj.Data.selected_entity[1][2], 1.0 / 640.0, 1.0 / 640.0)
  121.         Raster.SetTextColor(Label_r, Label_g, Label_b)
  122.         LabelEntity(pj.Data.selected_entity[0], pj.Data.selected_entity[1][2], 0, 0)
  123.     elif itime < 2.0:
  124.         Raster.SetTextColor(0, 0, 0)
  125.         Raster.SetTextAlpha(Label_Opacity * (2.0 - itime))
  126.         LabelEntity(pj.Data.selected_entity[0], pj.Data.selected_entity[1][2], 1.0 / 640.0, 1.0 / 640.0)
  127.         Raster.SetTextColor(Label_r, Label_g, Label_b)
  128.         LabelEntity(pj.Data.selected_entity[0], pj.Data.selected_entity[1][2], 0, 0)
  129.     
  130.  
  131.  
  132. def SelectionAfterFrameFunc(time):
  133.     import Scorer
  134.     if not (Scorer.VISIBLE):
  135.         return None
  136.     
  137.     pj = Bladex.GetEntity('Player1')
  138.     if pj is None:
  139.         return None
  140.     
  141.     if pj.Data is not None:
  142.         if pj.Data.selected_entity and pj.Data.selection_locked:
  143.             ShowLabelEntity(pj, time)
  144.         
  145.         Scorer.SetLifeValue(pj.Life, CharStats.GetCharMaxLife(pj.CharType, pj.Level), pj.Data.Poisoned)
  146.     
  147.     Scorer.SetLevelValue(pj.Level)
  148.     Scorer.SetEnemiesData(pj)
  149.     throw_pressed = Bladex.GetTimeActionHeld('Throw')
  150.     if throw_pressed:
  151.         Scorer.SetStrengthBarValue(Actions.ThrowTime2ThrowForce(throw_pressed))
  152.         Scorer.wLowBarFrame.SetVisible(1)
  153.     else:
  154.         max_energy = CharStats.GetCharMaxEnergy(pj.Kind, pj.Level)
  155.         if pj.Energy < max_energy:
  156.             Scorer.SetEnergyBarValue(pj.Energy, max_energy)
  157.             Scorer.wLowBarFrame.SetVisible(1)
  158.         else:
  159.             Scorer.wLowBarFrame.SetVisible(0)
  160.  
  161. if netgame.GetNetState() == 0:
  162.     Bladex.SetAfterFrameFunc('DefaultSelectionData', SelectionAfterFrameFunc)
  163.  
  164.